<template>
  <div class="app-container">
    <SearchForm
      v-show="showSearch"
      v-model="queryParams"
      :options="options.formOps"
      @onQuery="getList"
    >
    </SearchForm>
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <Table
      ref="table"
      :auto-featch="true"
      :fetch-data="fetchData"
      :options="options.table"
      :useAction="false"
    >
	<template #default>
	  <el-table-column label="已分配任务数" align="center" prop="countTask" key="countTask">
		<template #default="{ row }">
		  <el-button type="text" @click="showUserTask(row)">{{ row.countTask }}</el-button>
		</template>
	  </el-table-column>
	</template>
    </Table>
  </div>
  
  
  <el-dialog v-model="outerVisible" width="90%" title="风险分析清单明细">
    <template #default>
      <Inner ref="inner" :parentNode2="parentNode2"></Inner>
    </template>
  </el-dialog>
</template>

<script setup>
import Table from "@/components/Table/index.vue";
import SearchForm from "@/components/searchForm/index";
import { apis as APIS } from "@/api/yhpc/ryrwjl";
import formJson from "./fxdy.json";
import { useAsyncData, useFormJson } from "@/views/hooks/useAsyncData.js";
import Inner from "./inner.vue";

const outerVisible = ref(false);
const parentNode2 = ref({});
const ops = useFormJson(formJson, {
  sort: [],
  sortable: [],
});
const options = reactive({
  table: ops,
  formOps: ops.filter((i) =>
    ["userName", "nickName", "deptName", "fileStatus"].includes(i.prop)
  ),
});
const { proxy } = getCurrentInstance();
const props = defineProps({
  parentNode: {
    type: Object,
    default: () => ({}),
  },
});
const showSearch = ref(true);
const table = ref();
const { fetchData, getList, queryParams, form } = useAsyncData({
  APIS,
  formJson,
  table,
  proxy,
});
watch(
  () => props.parentNode,
  (val) => {
    queryParams.value.deptId = val.id || null;
    getList();
  },
  {
    deep: true,
  }
);

const showUserTask = (row) => {
  outerVisible.value = true;
  nextTick().then(() => {
	parentNode2.value.checkUserNames = row.nickName;
  });
};

</script>

<style lang="scss" scoped></style>
